<?php include (dirname(__FILE__)."/include/header.php"); ?>
 <style type="text/css">
<!--
a:link {
 text-decoration: none;
}
a:visited {
 text-decoration: none;
}
a:hover {
 text-decoration: none;
}
a:active {
 text-decoration: none;
}
-->
</style>
 <?php
if($_REQUEST['method']=="clear"){
	unset($_SESSION['_cart']);
	echo "<script>location.href='index_shop.php?shop_id=".$_REQUEST['shop_id']."';</script>";
}

if($_SESSION['_cart']['shop_id']!=$_REQUEST['shop_id']&&isset($_SESSION['_cart']['food'])){
	echo "<div id=\"showOtherCarNotice\" style=\"display:none\">false</div>";
}else{
	echo "<div id=\"showOtherCarNotice\" style=\"display:none\"></div>";
}
?>
<?php
//获取分类.
$shop_id = $_REQUEST['shop_id'];
$sql1 = "select * from zy_category where shop_id='" . $shop_id . "' order by sort";

//获取店铺基本信息
$sql3= "select * from zy_shop where shop_id='" . $shop_id . "'";
$result= mysql_query($sql3);
$shop = mysql_fetch_array($result);
?>
<div class="container">
  <ul class="breadcrumb">
    		<?php 
  	$shop_id=$_GET['shop_id'];
  	 $sql2="select * from zy_shop where shop_id='".$shop_id."'";
  	 // echo $sql2;
  	$query2=mysql_query($sql2);
  	if($query2=mysql_fetch_array($query2)){
  	?>
  	 <?php 
  		$sql="SELECT a.id id1,a.name name1,b.id id2 ,b.name name2,c.`id` id3 ,c.`name` name3 FROM zy_businessarea a LEFT JOIN zy_businessarea b ON a.`id`=b.`parentId` LEFT JOIN zy_businessarea c ON b.`id`=c.`parentId` WHERE c.`id`=".$query2['district']."";
  		//echo $sql;
  		$result=mysql_query($sql);
  		if($result=mysql_fetch_array($result)){?>
  			<li><a href="<?php echo SITE_ROOT ?>/index.php"><?php echo $result['name1'] ?>></a><a href="<?php echo SITE_ROOT ?>/index.php?id1=<?php echo $result['id2'];?>"><?php echo $result['name2'] ?></a>><a href="<?php echo SITE_ROOT ?>/index.php?id2=<?php echo $result['id3'];?>"><?php echo $result['name3']?></a>><?php echo $query2['shop_name'];?></li>
     <?php } }?>
      </ul>

	  
  <div class="row">
    <div class="span12 right-fold bordered-box">
      <div class="row">
        <div class="span12">
          <div class="important-info alert warning"><?php echo $shop['introduction'];?></div>
        </div>
        <div class="span9 master-side restaurant-content">
          <div class="row">
            <div class="span9">
              <ul class="nav nav-tabs restaurant-tab">
                <li class="active"><a href="<?php echo SITE_ROOT?>/index_shop.php?shop_id=<?php echo $shop_id;?>">菜单</a></li>
                <li><a href="<?php echo SITE_ROOT?>/shop/shop_evaluate.php?shop_id=<?php echo $shop_id;?>">评价</a></li>
                <li ><a href="<?php echo SITE_ROOT?>/shop/shop_message.php?shop_id=<?php echo $shop_id;?>">留言</a></li>
              </ul>
              <div class="restaurant-tab-content">
                <div class="menu-category-filter">
                  <ul>
                    <li rel="all" class="active" >所有美食</li>
                    <?php   $rs = mysql_query($sql1);;while ($cat = mysql_fetch_array($rs)) {?>
                      <li rel="<?php echo $cat['cat_id'];?>" ><?php echo $cat['cat_name'];?></li>
                    <?php } ?>
                  </ul>
                </div>
                <div class="menu">
                   <?php 
                   $rs = mysql_query($sql1);
                   while ($cat = mysql_fetch_array($rs)) {?>
                  <div class="food-category" id="food-category-<?php echo $cat['cat_id'];?>">
                    <h3 class="food-category-title"><?php echo $cat['cat_name'];?></h3>
                    <ul class="food-list">
                      <?php 
                      	$sql = "select zy_food.* from zy_food where cat_id=".$cat['cat_id']." and shop_id=".$cat['shop_id']." order by sort ";
						$result1 = mysql_query($sql);
						while($food=mysql_fetch_array($result1)){
					  ?>
					     <?php 
					     	if(isset($_SESSION['_user'])){
						     	$is_favo_food=0;
	                          	$is_favo_food_result=mysql_query("select count(favofood_id) a from zy_favofood where user_id=".$_SESSION['_user']['user_id']." and food_id=".$food['food_id']);
	                      		if($is_favo_food_result=mysql_fetch_array($is_favo_food_result)){
	                      			if($is_favo_food_result['a']>0){
	                      				$is_favo_food=1;
	                      			}
	                      		}
					     	}
                          ?>
                      <li class="food-item <?php if($is_favo_food==1){echo 'has-favor-icon';}?>" id="food-<?php echo $food['food_id'];?>">
					  <?php if($food['image']!=""){ ?>
                      <div id="image-<?php echo $food['food_id'];?>" class="food_image" style="display:none;">
                      
                      <img src="<?php echo SITE_ROOT;?><?php echo $food['image']?>" style="width:200px;height:150px;"/></div> 
					  <?php } ?>
                        <div class="line-one">
                        <div class="green_right"></div>
                        <div class="name"> 
						<span><?php echo $food['food_name'];?></span> 
                      <span class="food-icons-wrapper">
						</span> 
                        </div>
                        <div class="price"><?php echo $food['price'];?>元</div>
                        <div class="action"> <span class="food-action-wrapper with-add-to"> <a href="javascript:void(0);" class="food-action add-food add" food_id="<?php echo $food['food_id'];?>" food_name="<?php echo $food['food_name'];?>" price="<?php echo $food['price'];?>" entity_id=""></a> <a href="#" class="food-action add-to" entity_id=""></a> </span> </div>
                     	<div class="line-two" > 
                     	
						
						<a href="javascript:void(0);" class="hover-favor-food hidden" rel="<?php echo $food['food_id'];?>">收藏</a> 
                     	<a href="javascript:void(0);" class="hover-un-favor-food hidden" rel="<?php echo $food['food_id'];?>">取消收藏</a> </span> </div>
                     	
                      </li>
                      <div class="clear"></div>
                      <?php }?>
                    </ul>
                  </div>
                    <?php } ?>
                </div>
               
                <div id="modal-deliver-amount" class="modal hide fade" style="display: none; ">
                  <div class="modal-header"> <a href="#" class="close">×</a>
                    <h3>买单错误</h3>
                  </div>
                  <div class="modal-body"> </div>
                 <div class="modal-footer"> <a href="#" class="btn yellow complete">继续点单</a> </div>
                </div>
              </div>
            </div>
          </div>
        </div>
       <?php include (dirname(__FILE__)."/include/index_shop_right.php"); ?>
    </div>
  </div>
  <div class="food-category-selector">
    <div class="trigger" id="left-tab-cat">菜单分类</div>
    <div class="list" id="left-list-cat">
      <div class="head"> </div>
      <div class="title" > 菜单分类 </div>
      <ul>
      <?php	 $rs = mysql_query($sql1);
	  while ($cat = mysql_fetch_array($rs)){	?>
        <li rel="<?php echo $cat['cat_id'];?>"><a class="left-category" href="javascript:showCategory(<?php echo $cat['cat_id'] ?>);"><?php echo $cat['cat_name'];?></a></li>
        <?php } ?>
      </ul>
      <div class="foot"> </div>
    </div>
  </div>
<!--购物车-->
<div class="bottom-cart" id="bottom-cart" style="bottom: 0px">
  <div class="content">
    <div class="line-detail hidden">
      <table class="cart-detail-table table table-bordered table-striped hidden" id="cart-detail-table-1" style="display: table">
        <thead>
          <tr>
            <th class="name">美食名称</th>
            <th class="price">单价</th>
            <th class="quantity">数量</th>
            <th class="subtotal">总价</th>
            <th class="action"> <a class="cart-action cart-clear-group" href="index_shop.php?method=clear&shop_id=<?php echo $shop['shop_id'];?>">清空</a> <span class="cart-close"></span> </th>
          </tr>
        </thead>
        <tbody id="cart-details">
        <?php echo outputAllCartDetails(); ?>
        </tbody>
      </table>
      <table class="cart-detail-table table table-bordered table-striped hidden" id="cart-detail-table-empty" style="display: none">
        <thead>
          <tr>
            <th class="name">美食名称</th>
            <th class="price">单价</th>
            <th class="quantity">数量</th>
            <th class="subtotal">总价</th>
            <th class="action"> <a href="index_shop.php?method=clear&shop_id=<?php echo $shop['shop_id'];?>">清空</a> <span class="cart-close"></span> </th>
          </tr>
        </thead>
      </table>
    </div>
    <div class="line-brief" id="line-brief">
      <div class="col-restaurant-name"> @<?php echo $shop['shop_name'];?> </div>
      <div class="col-group active" id="col-group-1" rel="1" style="display: block"> 购物篮  </div>
      <div class="col-button">
        <button class="btn btn-yellow cart-btn"><span class="cart-checkout" id="bottom-car-checkout">买单</span></button>
      </div>
      <div class="col-total" id="col-total">
      <?php echo outputCartTotal();?>
      </div>
    </div>
    <div id="cart-add-effect"> <img src="<?php echo SITE_ROOT;?>/images/forward/cart/cart_arrow_down.png" alt="down_arrow"> </div>
  </div>
</div>
<!--购物车 结束-->
  <a id="back-to-top" href="javascript:void(0);">
  <div class="backtotop"></div>
  </a>
<?php include (dirname(__FILE__)."/include/footer.php"); ?>
<script type="text/javascript">
$(document).ready(function(){
//加载
	var dddd=$(".right-fold");
	var l=dddd.height();
	var bbbb=$(".right-fold").offset().top;
	var cccc=$(window).height();
	var k=$(window).scrollTop();
	var i=bbbb+l;
	var j=cccc+k-i-1;
	var m=$("#bottom-cart");
	if(j>0){
		m.css({bottom:j});
	}else{
		m.css({bottom:0});
	}
});
</script>